using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class AgingMap : EntityTypeConfiguration<Aging>
    {
        public AgingMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ID, t.CUST_CUR });

            // Properties
            this.Property(t => t.ID)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.CUST_CUR)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Aging");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.CUST_CUR).HasColumnName("CUST_CUR");
            this.Property(t => t.YTDSLS).HasColumnName("YTDSLS");
            this.Property(t => t.YTDSLSB1).HasColumnName("YTDSLSB1");
            this.Property(t => t.YTDSLSB2).HasColumnName("YTDSLSB2");
            this.Property(t => t.LASTSALEDT).HasColumnName("LASTSALEDT");
            this.Property(t => t.LSTSALEAMT).HasColumnName("LSTSALEAMT");
            this.Property(t => t.LSTSLAMTB1).HasColumnName("LSTSLAMTB1");
            this.Property(t => t.LSTSLAMTB2).HasColumnName("LSTSLAMTB2");
            this.Property(t => t.LASTPMT).HasColumnName("LASTPMT");
            this.Property(t => t.BALANCE).HasColumnName("BALANCE");
            this.Property(t => t.BALANCEB1).HasColumnName("BALANCEB1");
            this.Property(t => t.BALANCEB2).HasColumnName("BALANCEB2");
            this.Property(t => t.CURRENT).HasColumnName("CURRENT");
            this.Property(t => t.CURBASE1).HasColumnName("CURBASE1");
            this.Property(t => t.CURBASE2).HasColumnName("CURBASE2");
            this.Property(t => t.OVER30).HasColumnName("OVER30");
            this.Property(t => t.OVER30B1).HasColumnName("OVER30B1");
            this.Property(t => t.OVER30B2).HasColumnName("OVER30B2");
            this.Property(t => t.OVER60).HasColumnName("OVER60");
            this.Property(t => t.OVER60B1).HasColumnName("OVER60B1");
            this.Property(t => t.OVER60B2).HasColumnName("OVER60B2");
            this.Property(t => t.OVER90).HasColumnName("OVER90");
            this.Property(t => t.OVER90B1).HasColumnName("OVER90B1");
            this.Property(t => t.OVER90B2).HasColumnName("OVER90B2");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");

            // Relationships
            this.HasRequired(t => t.Cust)
                .WithMany(t => t.Agings)
                .HasForeignKey(d => d.ID);

        }
    }
}
